//
//  UpdateUserInfoH5Plugin.m
//  PCDBankSix
//
//  Created by APPLE on 2023/8/21.
//

#import "UpdateUserInfoH5Plugin.h"

@implementation UpdateUserInfoH5Plugin

- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback{
    //
    NSDictionary *dict = (NSDictionary *)data;
    
    
    self.bsContext = context;
    
    NSString *type = [dict objectForKey:@"type"];
    NSString *strCallback = dict[@"success"];
    
    
    //更新session信息
    NSDictionary *userInfo = dict[@"userInfo"];
    PCDLoginSession *loginSession = [PCDUtil loginSession];
    
    NSDictionary *loginSessionDic = loginSession.mj_keyValues;
    for (int i =0; i <userInfo.allKeys.count; i++) {
        NSString *tempKey = userInfo.allKeys[i];
        if ([[loginSessionDic allKeys] containsObject:tempKey]) {
            [loginSession setValue:userInfo[tempKey] forKey:tempKey];
        }
    }
    [PCDUtil saveLoginSession:loginSession];
    
    evaluateJavaScriptOnMainThread(self, strCallback, @"");
    
}

@end
